package com.aeks.finalkey;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.aeks.DB.OperateDB;

public class InsertData {
	public static boolean insertFinalKey(List<Map> list, String fileID) {
		boolean isSuccess = true;
		for(int i=0; i<list.size(); i++) {
			Map map = list.get(i);
			String sql = "insert into finalkey values(null, ?, ?, ?, ?, ?, ?)";
			List<Object> tlist = new ArrayList<Object>();
			tlist.add(fileID);
			tlist.add(map.get("length"));
			tlist.add(map.get("keyvalue"));
			tlist.add(map.get("freq"));
			tlist.add(map.get("cvalue"));
			tlist.add(map.get("iskey"));
			
			OperateDB.setList(tlist);
			int tn = OperateDB.getGeneratedKey(sql);
			if(tn == 0) {
				isSuccess = false;
				break;
			}
		}
		return isSuccess;
	}
}
